<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <div class="navbar navbar-default">
                            <form action="#" id="search-form2" class="navbar-form form-inline" method="post">
                                <div class="form-group">
                                    <label class="control-label" for="input-order-id">名称</label>
                                    <div class="input-group">
                                        <input type="text" name="name" placeholder="名称" id="input-order-id" class="input-sm">
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label class="control-label" for="input-order-id">类型</label>
                                    <div class="input-group">
                                        <select name="type" class="form-control">
                                            <option value="">请选择</option>
                                            <volist id="vo" name="Type">
                                                <option value="{$key}">{$vo}</option>
                                            </volist>
                                        </select>
                                    </div>
                                </div>


                                <div class="form-group">
                                    <button type="button" onclick="ajaxGetTable('search-form2', 1)" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</button>
                                </div>

                                <a href="{:U('banner/add_banner')}" class="btn btn-info pull-right" style = "margin:10px 0">添加轮播图</a>
                            </form>
                        </div>
                    </div>
                    <div class="box-body" id="ajax_return">

                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
    $(document).ready(function () {
        ajaxGetTable('search-form2', 1);
        $('#add_time').daterangepicker({
            format: "YYYY/MM/DD",
            singleDatePicker: false,
            showDropdowns: true,
            minDate: '2016/01/01',
            maxDate: '2030/01/01',
            startDate: '2016/01/01',
            locale: {
                applyLabel: '确定',
                cancelLabel: '取消',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '自定义',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                firstDay: 1
            }
        });
    });

    function delfun(obj) {
        if (confirm('确认删除')) {
            $.ajax({
                type: 'post',
                url: $(obj).attr('data-url'),
                data: {
                    act: 'del',
                    id: $(obj).attr('data-id')
                },
                dataType: 'json',
                success: function (data) {
                    if (data.code == 200) {
                        $(obj).parent().parent().remove();
                    } else {
                        layer.alert('删除失败', {
                            icon: 2
                        });
                    }
                }
            });
        }
        return false;
    }

    // ajax 抓取页面
    function ajaxGetTable(tab, page) {
        cur_page = page;
        $.ajax({
            type: "POST",
            url: "/index.php/Admin/banner/ajax_index/p/" + page,
            data: $('#' + tab).serialize(),
            success: function (data) {
                $("#ajax_return").html(data);
            }
        });
    }

    // 点击排序
    function sort(field) {
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajaxGetTable('search-form2', cur_page);
    }
</script>
</body>

</html>
